<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>replace</title>
</head>
<body>
<!--<script language="javascript">
    var strM = "javascript is a good script language";
    //在此我想将字母a替换成字母A
    alert(strM.replace("a","A"));
</script>-->
<!--<script language="javascript">
    var strM = "javascript is a good script language";
    //在此将字母a全部替换成字母A
    alert(strM.replace(/a/g,"A"));
</script>-->
<script language="javascript">
  /*  var strM = "javascript is a good script language";
    alert(strM.replace(/(javascript)\s*(is)/g,"$1 $2 fun. it $2"));*/

  /*  var reg=new RegExp("(http://www.qidian.com/BookReader/)(\\d+),(\\d+).aspx","gmi");
    var url="http://www.qidian.com/BookReader/1017141,20361055.aspx ";
    var rep=url.replace(reg,"$1ShowBook.aspx?bookId=$2&chapterId=$3");
    alert(rep);*/

  /*alert("push,unshift,remove,ensure".replace(/\w+/g,"method"));*/

  this.checkCard = function (num) {
      //var reg = /^[1-9]([0-9]{16}|[0-9]{13})[xX0-9]$/;
      //var reg = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;
      var reg1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;//15位数身份证
      var reg2 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;//18位数身份证
      return num && (reg2.test(num)||reg.test(num));
  };
    var num="14230319901228571X";

    alert(checkCard(num));







</script>

</body>
</html>